package 剑指offer;

/**
 * @author zhangjunfei
 * @date 2023/7/19 14:36
 */
public class O_57 {
    public int[] twoSum(int[] nums, int target) {
        int i = 0, j = nums.length - 1;
        while (i < nums.length && j != i) {

            if (nums[i] + nums[j] == target) {
                return new int[]{nums[i], nums[j]};
            }
            if (nums[i] + nums[j] < target) {
                i++;
            }
            if (nums[i] + nums[j] > target) {
                j--;
            }

        }
        return null;
    }
}
